<template>
  <div class="container">
    <g-header></g-header>
    <g-banner1 :img="data.ad.flash_img"></g-banner1>
    <div class="main-container">
      <g-nav :nav="data.nav" :name="data.belone_menu"></g-nav>
      <div class="list-container">
        <div class="title-container">
          <p class="title">{{data.belone_menu}}</p>
          <div class="hidden-in-xs breadcrumb">
            <span>当前位置：</span>
            <span>美梦首页></span>
            <span v-for="(item,index) in breadcrumb" :key="index">{{item.cate_name}}{{index==data.breadcrumb.length-1?'':'>'}}</span>
          </div>
        </div>

        <div class="item" v-for="(item,index) in data.list.data" :key="index" :class="{'border-right':index%2==0}">
            <img class="goods_file" :src="'http://localhost:8000'+item.goods_file1" alt="">
            <p class="goods_name">{{item.goods_name}}</p>
            <router-link :to="'../../../product/'+item.uid+'/'+$route.params.active"><p class="detail">查看详情</p></router-link>
        </div>

        <div class="page-container hidden-in-xs">
          共{{data.list.total}}条
          <router-link :to="'../../../productList/'+$route.params.id+'/1/'+$route.params.active">首页</router-link>
          <router-link v-show="$route.params.page>1" :to="'../../../productList/'+$route.params.id+'/'+parseInt($route.params.page-1)+'/'+$route.params.active">上一页</router-link>
          第{{data.list.current_page}}页
          <router-link v-show="data.list.last_page!=$route.params.page" :to="'../../../productList/'+$route.params.id+'/'+parseInt($route.params.page-0+1)+'/'+$route.params.active">下一页</router-link>
          <router-link :to="'../../../productList/'+$route.params.id+'/'+data.list.last_page+'/'+$route.params.active">末页</router-link>
        </div>
        <div class="page-container xs-only">
          <router-link :to="'../../../productList/'+$route.params.id+'/'+parseInt($route.params.page-1)+'/'+$route.params.active">
            <i class="fas fa-angle-left hidden" v-show="$route.params.page==1"></i>
          </router-link>
          <router-link :to="'../../../productList/'+$route.params.id+'/'+parseInt($route.params.page-1)+'/'+$route.params.active">
            <i class="fas fa-angle-left" v-show="$route.params.page>1"></i>
          </router-link>

          <input type="number" @keyup.enter="jump" min="1" :max="data.list.last_page" v-model="page" step="1">
          <span>/{{data.list.last_page}}</span>


          <router-link :to="'../../../productList/'+$route.params.id+'/'+parseInt($route.params.page-0+1)+'/'+$route.params.active">
            <i class="fas fa-angle-right" v-show="data.list.last_page!=$route.params.page"></i>
          </router-link>
          <router-link :to="'../../../productList/'+$route.params.id+'/'+parseInt($route.params.page-0+1)+'/'+$route.params.active">
            <i class="fas fa-angle-right hidden" v-show="data.list.last_page==$route.params.page"></i>
          </router-link>
        </div>
      </div>
    </div>
    <g-footer></g-footer>
  </div>
</template>
<script>
  import header from '@/components/header'
  import banner1 from '@/components/banner1'
  import nav from '@/components/nav'
  import footer from '@/components/footer'
  export default {
    components: {
      'g-header': header,
      'g-banner1': banner1,
      'g-nav': nav,
      'g-footer': footer
    },
    data() {
      return {
        data: {},
        page: this.$route.params.page
      }
    },
    created: function () {
      let that = this;
      this.$axios.get('http://localhost:8000/api/productList' + that.getArgs)
        .then(function (response) {
          console.log(response);
          that.data = response.data;
        })
        .catch(function (response) {
          console.log(response);
        })
    },
    computed: {
      getArgs: function () {
        return `?uid=${this.$route.params.id}&page=${this.$route.params.page}`
      },
      breadcrumb: function () {
        return this.data.breadcrumb.reverse()
      },
    },
    methods:{
      jump:function(){
        this.$router.push('/productList/'+this.$route.params.id+'/'+this.page+'/'+this.$route.params.active);
      }
    },
    watch: {
        getArgs:function(){
            let that = this;
      this.$axios.get('http://localhost:8000/api/productList' + that.getArgs)
        .then(function (response) {
          console.log(response);
          that.data = response.data;
        })
        .catch(function (response) {
          console.log(response);
        })
        }
    }
  }

</script>
<style lang="less" scoped>
  @import url('../style/mixin.less');
  .main-container {
    width: 1200px;
    margin: 60px auto 0;
    .On-xs( {
      width: calc(100% - 20px);
      margin: 0 10px;
    }
    );
    .list-container {
      width: 900px;
      margin-left: 20px;
      float: left;
      margin-bottom: 65px;
      .On-xs( {
        width: 100%;
        margin-left: 0;
        margin-bottom: 0;
      }
      );
      .title-container {
        border-bottom: 4px solid #a17657;
        height: 76px;
        .On-xs( {
          height: 40px;
          border-bottom: 2px solid #a17657;
        }
        );
        .title {
          float: left;
          height: 76px;
          line-height: 76px;
          font-family: MicrosoftYaHei;
          font-size: 20px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 1px;
          color: #543e2e;
          font-weight: bold;
          .On-xs( {
            font-size: 14px;
            line-height: 40px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #543e2e;
            height: 40px;
          }
          );
        }
        .breadcrumb {
          float: right;
          line-height: 76px;
          font-size: 14px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0px;
          color: #a17656;
          span:last-child {
            color: #543e2e;
          }
        }

      }
      .item{
          width: 200px;
          height: 280px;
          float: left;
          margin: 15px 12.5px;
          box-shadow: 3px 5px 12px 0px 
        rgba(161, 118, 87, 0.1);
        .On-xs({
            width: calc(50% - 1px);
            height: 254px;
            margin: 0;
            box-shadow: unset;
            border-bottom: 1px solid #a17656;                     
        });
        .goods_file{
            width: 200px;
            height: 200px;
            .On-xs({
                width: 147px;
                height: 147px;
                margin: 20px auto;
            });
        }
        .goods_name{
            width: 100%;
            text-align: center;
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            line-height: 16px;
            letter-spacing: 0px;
            color: #543e2e;
            margin-top: 12px;
              .Mult-line(1);
            .On-xs({
                width: calc(100% - 40px);
                text-align: left;
                font-size: 14px;
                font-weight: normal;
                font-stretch: normal;
                line-height: 14px;
                letter-spacing: 0px;
                color: #543e2e;
                margin: 0 auto;
            });
        }
        .detail{
            width: 100%;
            text-align: center;
            text-decoration: underline;
            font-size: 14px;
            font-weight: normal;
            font-stretch: normal;
            line-height: 14px;
            letter-spacing: 0px;
            color: #a17657;
            margin-top: 23px;
            .On-xs({
                width: calc(100% - 40px);
                text-align: left;
                font-size: 12px;
                font-weight: normal;
                font-stretch: normal;
                line-height: 12px;
                letter-spacing: 0px;
                color: #a17656;
                margin: 0 auto;
                margin-top: 21px;
            });
        }
        &.border-right{
            .On-xs({
                border-right: 1px solid #a17656;
            });
        }
      }
      .page-container.hidden-in-xs {
        height: 85px;
        width: 100%;
        float: left;
        font-size: 14px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 24px;
        letter-spacing: 1px;
        color: #543e2e;
        line-height: 125px;
        a {
          .A-all-state( {
            color: #a17657;
            text-decoration: none;
          }
          );
        }
      }
      .page-container.xs-only {
        height: 72px;
        float: left;
        width: 100%;
        font-size: 14px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 72px;
        letter-spacing: 0px;
        color: #a17656;
        i {
          color: #a17656;
          line-height: 72px;
          text-align: center;
          &.hidden {
            color: #eedac5;
          }
        }
        input {
          width: 27px;
          height: 32px;
          border-radius: 4px;
          border: solid 1px #eedac5;
          font-size: 14px;
          font-weight: normal;
          font-stretch: normal;
          line-height: 27px;
          letter-spacing: 0px;
          color: #a17656;
          text-align: center;
        }
      }
    }
  }

</style>
